package com.itheima.ydd.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * @author yan.zhou
 * @date 2022/1/22
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultData {
    private Integer errno;
    private String errmsg;
    private Object data;

    public static ResultData ok(String errmsg, Object data){
        return new ResultData(0, errmsg, data);
    }

    public static ResultData error(String errmsg){
        return new ResultData(1000, errmsg, null);
    }

    public static ResultData notLogin(){
        return new ResultData(9998, "未登录，不允许操作！", null);
    }

    public static ResultData ok2(Map<String, Object> data) {
        ResultData resultData = new ResultData();
        resultData.setErrmsg("");
        resultData.setErrno(0);
        resultData.setData(data);
        return resultData;
    }
}
